package com.zy.web.controller.bs;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zy.entity.bs.ActivityEnroll;
import com.zy.pojo.query.bs.ActivityEnrollQuery;
import com.zy.pojo.vos.common.PageVo;
import com.zy.pojo.vos.common.ResultVo;
import com.zy.service.bs.ActivityEnrollService;
import com.zy.web.controller.base.BaseController;
import com.zy.web.utils.ResultUtil;

import java.io.Serializable;

@RequestMapping({"bs/activityEnroll","m/bs/activityEnroll"})
@Controller
public class ActivityEnrollController extends BaseController {

	@Autowired
	private ActivityEnrollService activityEnrollService;

	/**
	 * 分页
 	 * 
 	 * @param activityEnrollQuery
	 * @param start
	 * @param limit
	 * @return
	 */
	@RequestMapping("pageActivityEnroll")
	@ResponseBody
	public PageVo pageActivityEnroll(ActivityEnrollQuery activityEnrollQuery, Integer start, Integer limit) {
		return this.activityEnrollService.pageActivityEnroll(activityEnrollQuery, start, limit);
	}

	/**
	 * 新增
	 * 
	 * @param activityEnroll
	 * @return
	 */
	@RequestMapping(value = "saveActivityEnroll", method = RequestMethod.POST)
	@ResponseBody
	public ResultVo saveActivityEnroll(ActivityEnroll activityEnroll) {
		try {
			this.activityEnrollService.saveActivityEnroll(activityEnroll);
			return ResultUtil.success();
		} catch (Exception e) {
			return ResultUtil.error(log, e);
		}
	}
	
	/**
	 * 更新
	 * 
	 * @param activityEnroll
	 * @return
	 */
	@RequestMapping(value = "updateActivityEnroll", method = RequestMethod.POST)
	@ResponseBody
	public ResultVo updateActivityEnroll(ActivityEnroll activityEnroll) {
		try {
			this.activityEnrollService.updateActivityEnroll(activityEnroll);
			return ResultUtil.success();
		} catch (Exception e) {
			return ResultUtil.error(log, e);
		}
	}

	/**
	 * 删除
	 * 
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "removeActivityEnroll", method = RequestMethod.POST)
	@ResponseBody
	public ResultVo removeActivityEnroll(long id) {
		try {
			this.activityEnrollService.removeActivityEnroll(id);
			return ResultUtil.success();
		} catch (Exception e) {
			return ResultUtil.error(log, e);
		}
	}

	/**
	 * 恢复
	 * 
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "recover", method = RequestMethod.POST)
	@ResponseBody
	public ResultVo recover(long id) {
		try {
			this.activityEnrollService.recover(id);
			return ResultUtil.success();
		} catch (Exception e) {
			return ResultUtil.error(log, e);
		}
	}

	@RequestMapping(value = "createOrderNo", method = RequestMethod.GET)
	@ResponseBody
	public ResultVo createOrderNo() {
		try {
			return ResultUtil.success(this.activityEnrollService.createOrderNo());
		} catch (Exception e) {
			return ResultUtil.error(log, e);
		}
	}
    @RequestMapping("front/getActivitiList")
    @ResponseBody
    public PageVo pageActivityEnroll(Long activityId, Integer start, Integer limit) {
        return this.activityEnrollService.getActivityList(11L, start, limit);
    }

}